package linuxbox.todo.logic;

import java.sql.*;

import linuxbox.*;

public class BoxTodoEntry
{
  protected int m_iID = 0;
  protected int m_UserID = -1;
  protected String m_sSubject = "";
  protected String m_sDescription = "";
  protected String m_sAssignedBy = "";
  protected String m_sCategory = "";
  protected int m_iPriority = 0;
  protected boolean m_bComplete = false;
  protected Timestamp m_StartDate = null;
  protected Timestamp m_DueDate = null;

  public void copyFrom(BoxTodoEntry entry)
  {
    m_iID = entry.getID();
    m_iPriority = entry.getPriority();
    m_bComplete = entry.getComplete();
    m_UserID = entry.getUserID();

    if (entry.getCategory() == null)
    {
      m_sCategory = null;
    }
    else
    {
      m_sCategory = new String(entry.getCategory());
    }
    if (entry.getSubject() == null)
    {
      m_sSubject = null;
    }
    else
    {
      m_sSubject = new String(entry.getSubject());
    }
    if (entry.getDescription() == null)
    {
      m_sDescription = null;
    }
    else
    {
      m_sDescription = new String(entry.getDescription());
    }
    if (entry.getAssignedBy() == null)
    {
      m_sAssignedBy = null;
    }
    else
    {
      m_sAssignedBy = new String(entry.getAssignedBy());

    }
    if (entry.getStartDate() == null)
    {
      m_StartDate = null;
    }
    else
    {
      m_StartDate = new Timestamp(entry.getStartDate().getTime());
    }
    if (entry.getDueDate() == null)
    {
      m_DueDate = null;
    }
    else
    {
      m_DueDate = new Timestamp(entry.getDueDate().getTime());
    }
  }

  public int getID()
  {
    return m_iID;
  }

  public void setID(int id)
  {
    m_iID = id;
  }

  public Timestamp getStartDate()
  {
    return m_StartDate;
  }

  public void setStartDate(Timestamp tm)
  {
    m_StartDate = tm;
  }

  public String getStartDateString()
  {
    if (m_StartDate == null)
    {
      return "";
    }
    else
    {
      BoxStatic.dateTimeFormatter.applyPattern(BoxStatic.SHORT_DATE_FORMAT);
      return BoxStatic.dateTimeFormatter.format(m_StartDate);
    }
  }

  public Timestamp getDueDate()
  {
    return m_DueDate;
  }

  public void setDueDate(Timestamp tm)
  {
    m_DueDate = tm;
  }

  public String getDueDateString()
  {
    if (m_DueDate == null)
    {
      return "";
    }
    else
    {
      BoxStatic.dateTimeFormatter.applyPattern(BoxStatic.SHORT_DATE_FORMAT);
      return BoxStatic.dateTimeFormatter.format(m_DueDate);
    }
  }

  public String getSubject()
  {
    return m_sSubject;
  }

  public void setSubject(String s)
  {
    m_sSubject = s;
  }

  public String getDescription()
  {
    return m_sDescription;
  }

  public void setDescription(String s)
  {
    m_sDescription = s;
  }

  public String getAssignedBy()
  {
    return m_sAssignedBy;
  }

  public void setAssignedBy(String s)
  {
    m_sAssignedBy = s;
  }

  public int getUserID()
  {
    return m_UserID;
  }

  public void setUserID(int s)
  {
    m_UserID = s;
  }

  public String getCategory()
  {
    return m_sCategory;
  }

  public void setCategory(String s)
  {
    m_sCategory = s;
  }

  public int getPriority()
  {
    return m_iPriority;
  }

  public void setPriority(int p)
  {
    m_iPriority = p;
  }

  public boolean getComplete()
  {
    return m_bComplete;
  }

  public void setComplete(boolean b)
  {
    m_bComplete = b;
  }

  public String toString()
  {
    String s = "id=" + m_iID
        + ", m_StartDate=" + m_StartDate
        + ", m_DueDate=" + m_DueDate
        + ", m_UserID=" + m_UserID
        + ", m_sSubject=" + m_sSubject
        + ", m_sDescription=" + m_sDescription
        + ", m_sAssignedBy=" + m_sAssignedBy
        + ", m_sCategory=" + m_sCategory
        + ", m_iPriority=" + m_iPriority
        + ", m_bComplete=" + m_bComplete
        + "\n";
    return s;
  }
}
